Imports BikiSoft.ALUUnit

Friend Class frmAUNodeTest

    Private dispNode As node = Nothing
    Private mCarBase As CarBase = Nothing

    Sub New(ByRef bikBase As CarBase)
        Me.InitializeComponent()
        mCarBase = bikBase
    End Sub

    Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
        Dim nPosition As UInt16 = 0
        Dim nValue As Single = 0
        Dim nCount As Integer = -1
        Dim arrBytes(9 * 32 - 1) As Byte
        For i As Integer = 0 To arrBytes.Length - 1
            arrBytes(i) = &HFF
        Next
        Try
            dispNode = New node(Me.tbCalculation.Text, nPosition, Nothing, 0)
            If cbClean.Checked Then
                dispNode.Clean()
                dispNode.Calculate()
            End If
            dispNode.Assign(nCount)
            dispNode.Output(arrBytes)

            'Array.Copy(arrBytes, 0, mCarBase.getBikSettings.getData, BikSettings.nAuFirstByte, arrBytes.Length)

            pbTreeDisplay.Refresh()

            Console.WriteLine("AU Count: " & dispNode.Units)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub pbTreeDisplay_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pbTreeDisplay.Paint

        Dim ptMarker As New Drawing.Point(10, 10)
        e.Graphics.CompositingQuality = CompositingQuality.HighQuality
        e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic

        If Not IsNothing(dispNode) Then
            dispNode.Draw(ptMarker, e.Graphics)
        End If
    End Sub
End Class